from ollama import chat
from ollama import Client


class ollama_cli():
    def __init__(self):
        self.client = Client(
        host='http://218.28.198.150:8055',
        headers={'x-some-header': 'some-value'}
        )
    def chat(self,messages):
        response = self.client.chat(model='deepseek-r1:32b',stream=True, messages=messages)
        return response


if __name__ == "__main__":
    cli = ollama_cli()
    messages = [{"role": "system", "content": "你现在是一名合格的植保员，请扮演好您的角色。"},{"role": "user", "content": "棉铃虫怎么防治"},]
    response = cli.chat(messages)
    for res in response:
        print(res["message"]["content"],end="",flush= True)
